package com.zfast.spring5.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Bean(name = "myDataSource")
    @Qualifier("myDataSource")
    @ConfigurationProperties(prefix="spring.zgnsource")
    //@MapperScan(basePackages = {"com.xxxxx.webApi.mapper.db1"}, sqlSessionFactoryRef = "sqlSessionFactoryDb1")
    public DataSource getMyDataSource(){
        return DataSourceBuilder.create()
                .build();
    }

    @Primary
    @Bean(name = "myDataSource2")
    @Qualifier("myDataSource2")
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource getMyDataSource2(){
        return DataSourceBuilder.create()
                .build();
    }
}